package com.simple.controller;

import com.simple.common.Result;
import com.simple.dto.BankDTO;
import com.simple.dto.IncomeDTO;
import com.simple.service.BankService;
import com.simple.service.IncomeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @ClassName BillController
 * @Author SimpleTree
 **/
@RestController
@RequestMapping("/income")
public class IncomeController {

    @Autowired
    private IncomeService incomeService;

    @GetMapping
    public Result getIncomes(IncomeDTO incomeDTO) {
        return Result.of(incomeService.getIncomes(incomeDTO));
    }


    @GetMapping("/getIncomeById/{id}")
    public Result getIncomeById(@PathVariable("id")Integer id) {
        return Result.of(incomeService.getIncomeById(id));
    }


    @PostMapping
    public Result saveIncome(@RequestBody IncomeDTO incomeDTO) {
        incomeService.saveIncome(incomeDTO);
        return Result.of();
    }

    @PutMapping
    public Result updateBank(@RequestBody IncomeDTO incomeDTO) {
        incomeService.updateIncome(incomeDTO);
        return Result.of();
    }

    @DeleteMapping
    public Result deleteByIds(@RequestParam List<Integer> ids) {
        incomeService.deleteByIds(ids);
        return Result.of();
    }
}
